﻿using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text;
using Maticsoft.Common;
namespace Lawyer.Web.AgencyInfo
{
    public partial class Add : Page
    {
        protected void Page_Load(object sender, EventArgs e)
        {
                       
        }

        		protected void btnSave_Click(object sender, EventArgs e)
		{
			
			string strErr="";
			if(this.txtAgencyID.Text.Trim().Length==0)
			{
				strErr+="AgencyID不能为空！\\n";	
			}
			if(this.txtName.Text.Trim().Length==0)
			{
				strErr+="Name不能为空！\\n";	
			}
			if(!PageValidate.IsDecimal(txtAgencyRate.Text))
			{
				strErr+="AgencyRate格式错误！\\n";	
			}
			if(this.txtEmail.Text.Trim().Length==0)
			{
				strErr+="Email不能为空！\\n";	
			}
			if(this.txtCity.Text.Trim().Length==0)
			{
				strErr+="City不能为空！\\n";	
			}
			if(this.txtTelphone.Text.Trim().Length==0)
			{
				strErr+="Telphone不能为空！\\n";	
			}
			if(this.txtFax.Text.Trim().Length==0)
			{
				strErr+="Fax不能为空！\\n";	
			}
			if(this.txtAddress.Text.Trim().Length==0)
			{
				strErr+="Address不能为空！\\n";	
			}
			if(this.txtAvatarURL.Text.Trim().Length==0)
			{
				strErr+="AvatarURL不能为空！\\n";	
			}
			if(!PageValidate.IsNumber(txtStatus.Text))
			{
				strErr+="Status格式错误！\\n";	
			}
			if(this.txtNote.Text.Trim().Length==0)
			{
				strErr+="Note不能为空！\\n";	
			}
			if(this.txtCreatedBy.Text.Trim().Length==0)
			{
				strErr+="CreatedBy不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtCreatedDate.Text))
			{
				strErr+="CreatedDate格式错误！\\n";	
			}
			if(this.txtUpdatedby.Text.Trim().Length==0)
			{
				strErr+="Updatedby不能为空！\\n";	
			}
			if(!PageValidate.IsDateTime(txtUpdatedDate.Text))
			{
				strErr+="UpdatedDate格式错误！\\n";	
			}

			if(strErr!="")
			{
				MessageBox.Show(this,strErr);
				return;
			}
			string AgencyID=this.txtAgencyID.Text;
			string Name=this.txtName.Text;
            Double AgencyRate = Double.Parse(this.txtAgencyRate.Text);
			string Email=this.txtEmail.Text;
			string City=this.txtCity.Text;
			string Telphone=this.txtTelphone.Text;
			string Fax=this.txtFax.Text;
			string Address=this.txtAddress.Text;
			string AvatarURL=this.txtAvatarURL.Text;
			int Status=int.Parse(this.txtStatus.Text);
			string Note=this.txtNote.Text;
			string CreatedBy=this.txtCreatedBy.Text;
			DateTime CreatedDate=DateTime.Parse(this.txtCreatedDate.Text);
			string Updatedby=this.txtUpdatedby.Text;
			DateTime UpdatedDate=DateTime.Parse(this.txtUpdatedDate.Text);

			Lawyer.Model.AgencyInfo model=new Lawyer.Model.AgencyInfo();
			model.AgencyID=AgencyID;
			model.Name=Name;
			model.AgencyRate=AgencyRate;
			model.Email=Email;
			model.City=City;
			model.Telphone=Telphone;
			model.Fax=Fax;
			model.Address=Address;
			model.AvatarURL=AvatarURL;
			model.Status=Status;
			model.Note=Note;
			model.CreatedBy=CreatedBy;
			model.CreatedDate=CreatedDate;
			model.Updatedby=Updatedby;
			model.UpdatedDate=UpdatedDate;

			Lawyer.BLL.AgencyInfo bll=new Lawyer.BLL.AgencyInfo();
			bll.Add(model);
			Maticsoft.Common.MessageBox.ShowAndRedirect(this,"保存成功！","add.aspx");

		}


        public void btnCancle_Click(object sender, EventArgs e)
        {
            Response.Redirect("list.aspx");
        }
    }
}
